<%@page import="accessor.DepartmentAccessor"%>
<%@page import="accessor.Department"%>
<%@page import="accessor.UserAccessor"%>
<%@page import="accessor.User"%>
<%@page import="java.util.List"%>
<%@include file="header.jsp" %>
<%@include file="menubar/adminmenu.jsp" %>
<div class="break_line"></div>
<div class="break_line"></div>
<% 
    UserAccessor userAccessor = new UserAccessor();
    DepartmentAccessor departmentAccessor = new DepartmentAccessor();
    List<Department> departments = departmentAccessor.getAll();
    session = request.getSession();
%>
<div id="content">
    <form method="POST" action="../add_user" onsubmit="return go();">
        <div id="title_content">ADD USER</div>
        <table class="form_content" width="100%">
        <tr>
            <td width="20%">FIRST NAME</td>
            <td>
                <%if(session.getAttribute("add_first_name")!=null){%>
                <div class="form_error"><%=session.getAttribute("add_first_name")%></div>
                <%}%>
                <input type="text" class="form_input" name="first_name" size="35" maxlength="40" value="<%= request.getSession().getAttribute("val_first_name")!=null?request.getSession().getAttribute("val_first_name"):"" %>" />
            </td>
        </tr>
        <tr>
            <td>LAST NAME</td>
            <td>
                <% if(session.getAttribute("add_last_name") != null) {%> 
                <div class="form_error"><%=session.getAttribute("add_first_name")%></div>  
                <% }%>
                <input type="text" class="form_input" name="last_name" size="35" maxlength="40" value="<%= session.getAttribute("val_last_name")!=null?session.getAttribute("val_last_name"):""%>" /></td>
        </tr>
        <tr>
            <td>EMAIL</td>
            <td>
                <% if(session.getAttribute("add_email") != null) {%> 
                <div class="form_error"><%=session.getAttribute("add_email")%></div>  
                <% }%>
                <input type="text" class="form_input" name="email" size="35" maxlength="40" value="<%= request.getSession().getAttribute("val_email")!=null?request.getSession().getAttribute("val_email"):""%>" /></td>
        </tr>
        <tr>
                <td>DEPARTMENT NAME: </td>
                <td>
                    <select name="departmentID" id="departmentID" >
                        <%
                            for (int i = 0; i < departments.size(); i++) {
                                Department d = (Department) departments.get(i);
                        %>
                        <option
                            value="<%=d.getDepartmentID()%>"><%=d.getDepartmentName()%></option>
                        <%}%>
                    </select>
                </td>
            </tr>
            <tr>
                <td>DATE OF BIRTH: </td>
                <td><input type="text" id="date" name="dateOfBirth" class="form_input" value="2011-01-01"/></td>
            </tr>
        <tr>
            <td colspan="2"><input type="submit" name="register" value="ADD" class="form_submit" /></td>
        </tr>
    </table>
    </form>
</div>
<!--END content-->
<%@include file="footer.jsp" %>